package com.yiwei.zhh.impl;

import android.content.Context;

import com.yiwei.zhh.constant.Const;
import com.yiwei.zhh.http.CallBackListener;
import com.yiwei.zhh.http.InterfaceServer;
import com.yiwei.zhh.interfaces.BeginApplyInfo;
import com.yiwei.zhh.http.InfoCallBack;
import com.yiwei.zhh.model.BeginApplyModel;
import com.yiwei.zhh.model.RequestModel;

import java.util.HashMap;

/**
 * 开始贷款
 */
public class BeginApplyInfoImpl implements BeginApplyInfo {
    public void getBeginApplyInfo(Context paramContext, String dealId, final InfoCallBack callBack) {
        HashMap localHashMap = new HashMap();
        localHashMap.put("id", dealId);
        RequestModel model = new RequestModel(localHashMap);

        InterfaceServer.getInstance(paramContext.getApplicationContext()).requestInterface(Const.BEGIN_APPLY, Const.RequestMethod.POST, model, Const.DEFAULT_TIMEOUT,new CallBackListener<BeginApplyModel>(BeginApplyModel.class,callBack));
//                new ResponseListener() {
//
//            @Override
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            @Override
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    BeginApplyModel model = (BeginApplyModel) result;
//                    if (model.getStatus() == 0) callBack.onFailure(model.getMsg());
//                    else
//                        callBack.onSuccess(model);
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<BeginApplyModel>fromJson(content, BeginApplyModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    @Override
    public void getNewBeginApplyInfo(Context paramContext, String dealId, final InfoCallBack callBack) {
        HashMap localHashMap = new HashMap();
        localHashMap.put("id", dealId);
        RequestModel model = new RequestModel(localHashMap);

        InterfaceServer.getInstance(paramContext.getApplicationContext()).requestInterface(Const.NEW_BEGIN_APPLY, Const.RequestMethod.POST, model, Const.DEFAULT_TIMEOUT, new CallBackListener<BeginApplyModel>(BeginApplyModel.class,callBack));
//                new ResponseListener() {
//
//            @Override
//            public void onFinishInMainThread(Object object) {
//            }
//
//            @Override
//            public void onStartInMainThread(Object object) {
//                callBack.onFailure(object.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    BeginApplyModel model = (BeginApplyModel) result;
//                    if (model.getStatus() == 0) callBack.onFailure(model.getMsg());
//                    else
//                        callBack.onSuccess(model);
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<BeginApplyModel>fromJson(content, BeginApplyModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    public void getSubmitApplyInfo(Context paramContext, String paramInt, String paramString1, String paramString2, final InfoCallBack callBack) {
        HashMap localHashMap = new HashMap();
        localHashMap.put("deal_id", paramInt);
        localHashMap.put("lat", paramString1);
        localHashMap.put("lng", paramString2);
        RequestModel model = new RequestModel(localHashMap);
        InterfaceServer.getInstance(paramContext.getApplicationContext()).requestInterface(Const.SUBMIT_APPLY, Const.RequestMethod.POST, model, Const.DEFAULT_TIMEOUT, new CallBackListener<BeginApplyModel>(BeginApplyModel.class,callBack));
//                new ResponseListener() {
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    BeginApplyModel model = (BeginApplyModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model);
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<BeginApplyModel>fromJson(content, BeginApplyModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }
}
